<?php
	# experiences.php
	# Experiences page of the portfolio 
	# 2013-May

    // Set current page id as a session variable
    $_SESSION['currId'] = 'Experience';
?>

<?php
	# Formats an experience list of tasks in a printable manner.
	# Ex: The task list 'task1;task2;task3' will be laid in a list.
	function format_exp_tasks($tasks)
	{
		$tabTasks = explode(';', $tasks);
		$taskList = '';
		for ($i = 0; $i < count($tabTasks); ++$i)
		{
			$taskList .= '* ' . $tabTasks[$i] . '<br />';
		}
		
		return $taskList;
	}
?>

<!-- Expérience professionnelle -->
<span id="subject"><?php print $txt_work_experience; ?></span>
<br />
<?php
	$query_exps = "SELECT exp.exp_title_fr, exp.exp_title_en, exp.exp_company, exp.exp_location, exp.exp_tasks_fr, exp.exp_tasks_en, exp.exp_startdate, exp.exp_enddate, expt.name_fr, expt.name_en
					FROM experience exp
					LEFT JOIN experience_types expt ON expt.id = exp.exp_typeid
					ORDER BY exp.exp_startdate DESC";
					
	$result_exps = mysql_query($query_exps);
	
	# Number of referencies
	$num_exps = mysql_num_rows($result_exps);

    # Get the current language
    if (!isset($_COOKIE['lang'])){
        $currLang = 'fr';
    }
    else
        $currLang = $_COOKIE['lang'];
?>

<table class="tabPanel">
	<?php
		while (false !== ($row_exp = mysql_fetch_array($result_exps)))
		{
			print '<tr>';
				print '<td>';
					print '<div class="panel style-8">';
						print '<div>';
							print '<h5>' . utf8_encode($row_exp['exp_title_' . $currLang]) . ' - '
										. utf8_encode($row_exp['exp_company']) . ', ' . utf8_encode($row_exp['exp_location']) . '</h5>';
							print  '<center><i>(' . utf8_encode($row_exp['name_' . $currLang]) . ')</i></center>';
							print '<p>';
								print format_date1(strtotime($row_exp['exp_startdate'])) . ' - ' 
									. format_date1(strtotime($row_exp['exp_enddate'])) . '<br /><br />';
								print format_exp_tasks(utf8_encode($row_exp['exp_tasks_' . $currLang]));
							print '</p>';
						print '</div>';
					print '</div>';
				print '</td>';
			print '</tr>';
		}
	?>
</table>